package demo;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.*;
import java.util.concurrent.Executor;

/**
 * User: yian
 * Date: 2018/3/12
 */
public class Consumer {
    public static void main(String[] args) throws Exception {


        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
                new String[]{"dubbo-demo-consumer.xml"});
        context.start();
        // obtain proxy object for remote invocation
        DemoService demoService = (DemoService) context.getBean("demoService");
        // execute remote invocation
        while (true){
            try {
                System.out.println("----------------------");
                demoService.sayHello(new Date().toString());
                Thread.sleep(300000000);
            } catch (Exception e) {
                e.printStackTrace();
            }

        }

    }

//    private static void print(DemoService demoService) {
//        ArrayList<String> strings = new ArrayList();
//        for(int i=0;i<100;i++){
//
//            String hello = demoService.sayHello("world");
//            strings.add(hello);
//            // show the result
//
//        }
//        Collections.sort(strings);
//        System.out.println(strings);
//    }
}

